package com.yyh.myblog.service;

import com.yyh.myblog.dao.UserRepository;
import com.yyh.myblog.entity.User;
import com.yyh.myblog.util.MD5Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author yyh
 * @date 2021/2/22 15:04
 * 定义的UserService具体实现方法
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserRepository userRepository;

    /**
     * 构造注入
     */
//    private final UserRepository userRepository;
//
//    public UserServiceImpl(UserRepository userRepository) {
//        this.userRepository = userRepository;
//    }

    @Override
    public User checkUser(String username, String password) {
        User user = userRepository.findByUsernameAndPassword(username , MD5Utils.code(password));
        return user;
    }
}
